package com.campus.entity;


import java.util.Random;

public class RandomCaptcha {
    public static String getRandomString(int length) {
        String[] codeChars = {"0", "1", "2", "3", "4", "5", "6", "7", "8", "9",
                "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N",
                "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"};

        StringBuilder code = new StringBuilder();
        Random random = new Random();

        for (int i = 0; i < length; i++) {
            int index = random.nextInt(codeChars.length);
            code.append(codeChars[index]);
        }

        return code.toString();
    }

}
